package com.bootdo.staff.service.impl;

import com.bootdo.common.utils.AppR;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.bootdo.staff.dao.StaffMenuRoleDao;
import com.bootdo.staff.domain.StaffMenuRoleDO;
import com.bootdo.staff.service.StaffMenuRoleService;
import org.springframework.transaction.annotation.Transactional;


@Service
@Transactional
public class StaffMenuRoleServiceImpl implements StaffMenuRoleService {
	@Autowired
	private StaffMenuRoleDao staffMenuRoleDao;
	
	@Override
	public StaffMenuRoleDO get(Long id){
		return staffMenuRoleDao.get(id);
	}
	
	@Override
	public List<StaffMenuRoleDO> list(Map<String, Object> map){
		return staffMenuRoleDao.list(map);
	}
	
	@Override
	public int count(Map<String, Object> map){
		return staffMenuRoleDao.count(map);
	}
	
	@Override
	public int save(StaffMenuRoleDO staffMenuRole){
		return staffMenuRoleDao.save(staffMenuRole);
	}
	
	@Override
	public int update(StaffMenuRoleDO staffMenuRole){
		return staffMenuRoleDao.update(staffMenuRole);
	}
	
	@Override
	public int remove(Long id){
		return staffMenuRoleDao.remove(id);
	}
	
	@Override
	public int batchRemove(Long[] ids){
		return staffMenuRoleDao.batchRemove(ids);
	}


	/**
	 * 获取用户是否有权访问该菜单
	 * @return
	 */
	@Override
	public AppR getIsRole(Long staffId , Long smenuId){
		Map<String,Object> map = new HashMap<>();
		map.put("staffId",staffId);
		map.put("smenuId",smenuId);
		if (staffMenuRoleDao.getIsRole(map)==null)
			return AppR.error(1003,"没有权限");
		return AppR.ok();
	}
	/**
	 * 修改用户状态
	 */
	@Override
	public int updateUserState(StaffMenuRoleDO staffMenuRoleDO) {
		// TODO Auto-generated method stub
		return staffMenuRoleDao.updateUserState(staffMenuRoleDO);
	}
	
}
